<template>
    <div>
        <Row :gutter="10">
            <Form v-model="formValidate"  ref="formValidate" :label-width="120">
                <FormItem label="商品租赁支付" prop="order_pay">
                    <RadioGroup v-model="formValidate.order_pay">
                        <Radio label="1">开启</Radio>
                        <Radio label="0">关闭</Radio>
                    </RadioGroup>
                </FormItem>
                <FormItem label="企业认证审核" prop="user_auth_audit ">
                    <RadioGroup v-model="formValidate.user_auth_audit ">
                        <Radio label="1">开启</Radio>
                        <Radio label="0">关闭</Radio>
                    </RadioGroup>
                </FormItem>
                <FormItem label="管理员推送" prop="open_push_admin ">
                    <RadioGroup v-model="formValidate.open_push_admin ">
                        <Radio label="1">开启</Radio>
                        <Radio label="0">关闭</Radio>
                    </RadioGroup>
                </FormItem>
                <FormItem label="关于我们" prop="about" class="label_required">
                    <NEditor v-if="!spinShow" :msg="formValidate.about" @changeMsg="changeMsg" style="width:60%"></NEditor>
                </FormItem>
                <FormItem>
                    <Button type="primary" @click="handleSubmit()" style="width: 90px;height: 35px;border-radius: 0;font-size: 14px;">提交</Button>
                </FormItem>
            </Form>
        </Row>
    </div>
</template>
<script>
    import { setting, getSettingInfo} from '@/api/main'
    export default {
        data() {
            return {
                spinShow: false,
                formValidate: {
                    order_pay: '0',
                    user_auth_audit: '0',
                    open_push_admin: '0',
                    about: '',
                },
            }
        },
        methods: {
            changeMsg (msg) {
                this.formValidate.about = msg
            },
            init() {
                getSettingInfo().then(res => {
                    if (res.code == 0) {
                        this.spinShow = true
                        this.formValidate.order_pay = res.data.order_pay.toString()
                        this.formValidate.user_auth_audit  = res.data.user_auth_audit .toString()
                        this.formValidate.open_push_admin  = res.data.open_push_admin .toString()
                        this.about = res.data.about
                        setTimeout(() => {
                            this.spinShow = false
                        }, 1)
                    } else {
                        this.$Message.error(res.text)
                    }
                })
            },
            handleSubmit () {
                setting(this.formValidate).then(res => {
                    if (res.code == 0) {
                        this.$Message.success('保存成功')
                    } else {
                        this.$Message.error(res.text)
                    }
                })
            }
        },
        mounted() {
            this.init()
        },
    }
</script>
